<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机点名</title>
</head>
<body>
   <!-- 随机点名:点击网页中‘点名’按钮，随机将数组中的名字显示到网页
    数组，随机数（math.random()).事件绑定，设置文本内容.
     -->
    <button>点名</button>
    <h3>显示名字</h3>
    <script>
        const btn = document.querySelector('button');
        const text = document.querySelector('h3');
        let arr = ['a','b','c','d'];
        btn.addEventListener('click',function(){
            //获取数组的随机索引值num[0~arr.length]
            //let num = Math.floor(math.random()*arr.length);
            let num = math.floor(Math.random()*59);
            //通过num获取数组的随机值
            //
            text.innerHTML = num;
        })
        
    </script>
</body>
</html>